#ifndef WRAP_PRCTL_H
#define WRAP_PRCTL_H

namespace Wrap {
constexpr int PRE_SET_NAME_ = 15;

/// @see https://man7.org/linux/man-pages/man2/prctl.2.html
/// @return On success, PR_CAP_AMBIENT+PR_CAP_AMBIENT_IS_SET, PR_CAPBSET_READ,
/// PR_GET_DUMPABLE, PR_GET_FP_MODE, PR_GET_IO_FLUSHER, PR_GET_KEEPCAPS,
/// PR_MCE_KILL_GET, PR_GET_NO_NEW_PRIVS, PR_GET_SECUREBITS,
/// PR_GET_SPECULATION_CTRL, PR_SVE_GET_VL, PR_SVE_SET_VL,
/// PR_GET_TAGGED_ADDR_CTRL, PR_GET_THP_DISABLE, PR_GET_TIMING,
/// PR_GET_TIMERSLACK, and (if it returns) PR_GET_SECCOMP return the
/// nonnegative values described above.  All other option values return 0 on
/// success. On error, -1 is returned, and errno is set to indicate the error.
/// @throw EACCES @c option is PR_SET_SECCOMP and @c ...arg2 is
/// SECCOMP_MODE_FILTER, but the process does not have the CAP_SYS_ADMIN
/// capability or has not set the no_new_privs attribute (see the discussion of
/// PR_SET_NO_NEW_PRIVS above).
/// @throw EACCES @c option is PR_SET_MM, and @c ...arg3 is PR_SET_MM_EXE_FILE,
/// the file is not executable.
/// @throw EBADF @c option is PR_SET_MM, @c ...arg3 is PR_SET_MM_EXE_FILE, and
/// the file descriptor passed in @c ...arg4 is not valid.
/// @throw EBUSY @c option is PR_SET_MM, @c ...arg3 is PR_SET_MM_EXE_FILE, and
/// this the second attempt to change the /proc/pid/exe symbolic link, which is
/// prohibited.
/// @throw EFAULT @c ...arg2 is an invalid address.
/// @throw EFAULT @c option is PR_SET_SECCOMP, @c ...arg2 is
/// SECCOMP_MODE_FILTER, the system was built with CONFIG_SECCOMP_FILTER, and @c
/// ...arg3 is an invalid address.
/// @throw EINVAL The value of @c option is not recognized, or not supported on
/// this system.
/// @throw EINVAL @c option is PR_MCE_KILL or PR_MCE_KILL_GET or PR_SET_MM, and
/// unused prctl() arguments were not specified as zero.
/// @throw EINVAL @c ...arg2 is not valid value for this @c option.
/// @throw EINVAL @c option is PR_SET_SECCOMP or PR_GET_SECCOMP, and the kernel
/// was not configured with CONFIG_SECCOMP.
/// @throw EINVAL @c option is PR_SET_SECCOMP, @c ...arg2 is
/// SECCOMP_MODE_FILTER, and the kernel was not configured with
/// CONFIG_SECCOMP_FILTER.
/// @throw EINVAL @c option is PR_SET_MM, and one of the following is true *  @c
/// ...arg4 or @c ...arg5 is nonzero; *  @c ...arg3 is greater than TASK_SIZE
/// (the limit on the size of the user address space for this architecture); *
/// @c ...arg2 is PR_SET_MM_START_CODE, PR_SET_MM_END_CODE,
/// PR_SET_MM_START_DATA, PR_SET_MM_END_DATA, or PR_SET_MM_START_STACK, and the
/// permissions of the corresponding memory area are not as required; *  @c
/// ...arg2 is PR_SET_MM_START_BRK or PR_SET_MM_BRK, and @c ...arg3 is less than
/// or equal to the end of the data segment or specifies a value that would
/// cause the RLIMIT_DATA resource limit to be exceeded.
/// @throw EINVAL @c option is PR_SET_PTRACER and @c ...arg2 is not 0,
/// PR_SET_PTRACER_ANY, or the PID of an existing process.
/// @throw EINVAL @c option is PR_SET_PDEATHSIG and @c ...arg2 is not a valid
/// signal number.
/// @throw EINVAL @c option is PR_SET_DUMPABLE and @c ...arg2 is neither
/// SUID_DUMP_DISABLE nor SUID_DUMP_USER.
/// @throw EINVAL @c option is PR_SET_TIMING and @c ...arg2 is not
/// PR_TIMING_STATISTICAL.
/// @throw EINVAL @c option is PR_SET_NO_NEW_PRIVS and @c ...arg2 is not equal
/// to 1 or @c ...arg3, @c ...arg4, or @c ...arg5 is nonzero.
/// @throw EINVAL @c option is PR_GET_NO_NEW_PRIVS and @c ...arg2, @c ...arg3,
/// @c ...arg4, or @c ...arg5 is nonzero.
/// @throw EINVAL @c option is PR_SET_THP_DISABLE and @c ...arg3, @c ...arg4, or
/// @c ...arg5 is nonzero.
/// @throw EINVAL @c option is PR_GET_THP_DISABLE and @c ...arg2, @c ...arg3, @c
/// ...arg4, or @c ...arg5 is nonzero.
/// @throw EINVAL @c option is PR_CAP_AMBIENT and an unused argument (@c
/// ...arg4, @c ...arg5, or, in the case of PR_CAP_AMBIENT_CLEAR_ALL, @c
/// ...arg3) is nonzero; or @c ...arg2 has an invalid value; or @c ...arg2 is
/// PR_CAP_AMBIENT_LOWER, PR_CAP_AMBIENT_RAISE, or PR_CAP_AMBIENT_IS_SET and @c
/// ...arg3 does not specify a valid capability.
/// @throw EINVAL @c option was PR_GET_SPECULATION_CTRL or
/// PR_SET_SPECULATION_CTRL and unused arguments to prctl() are not 0.
/// @throw  EINVAL @c option is PR_PAC_RESET_KEYS and the arguments are invalid
/// or unsupported.  See the description of PR_PAC_RESET_KEYS above for details.
/// @throw EINVAL @c option is PR_SVE_SET_VL and the arguments are invalid or
/// unsupported, or SVE is not available on this platform.  See the description
/// of PR_SVE_SET_VL above for details.
/// @throw EINVAL @c option is PR_SVE_GET_VL and SVE is not available on this
/// platform.
/// @throw EINVAL @c option is PR_SET_TAGGED_ADDR_CTRL and the arguments are
/// invalid or unsupported.  See the description of PR_SET_TAGGED_ADDR_CTRL
/// above for details.
/// @throw EINVAL @c option is PR_GET_TAGGED_ADDR_CTRL and the arguments are
/// invalid or unsupported.  See the description of PR_GET_TAGGED_ADDR_CTRL
/// above for details.
/// @throw ENODEV @c option was PR_SET_SPECULATION_CTRL the kernel or CPU does
/// not support the requested speculation misfeature.
/// @throw ENXIO @c option was PR_MPX_ENABLE_MANAGEMENT or
/// PR_MPX_DISABLE_MANAGEMENT and the kernel or the CPU does not support MPX
/// management.  Check that the kernel and processor have MPX support.
/// @throw ENXIO @c option was PR_SET_SPECULATION_CTRL implies that the control
/// of the selected speculation misfeature is not possible.  See
/// PR_GET_SPECULATION_CTRL for the bit fields to determine which option is
/// available.
/// @throw EOPNOTSUPP @c option is PR_SET_FP_MODE and @c ...arg2 has an invalid
/// or unsupported value.
/// @throw EPERM @c option is PR_SET_SECUREBITS, and the caller does not have
/// the CAP_SETPCAP capability, or tried to unset a "locked" flag, or tried to
/// set a flag whose corresponding locked flag was set (see capabilities(7)).
/// @throw EPERM @c option is PR_SET_SPECULATION_CTRL wherein the speculation
/// was disabled with PR_SPEC_FORCE_DISABLE and caller tried to enable it again.
/// @throw EPERM @c option is PR_SET_KEEPCAPS, and the caller's
/// SECBIT_KEEP_CAPS_LOCKED flag is set (see capabilities(7)).
/// @throw EPERM @c option is PR_CAPBSET_DROP, and the caller does not have the
/// CAP_SETPCAP capability.
/// @throw EPERM @c option is PR_SET_MM, and the caller does not have the
/// CAP_SYS_RESOURCE capability.
/// @throw EPERM @c option is PR_CAP_AMBIENT and @c ...arg2 is
/// PR_CAP_AMBIENT_RAISE, but either the capability specified in @c ...arg3 is
/// not present in the process's permitted and inheritable capability sets, or
/// the PR_CAP_AMBIENT_LOWER securebit has been set.
/// @throw ERANGE @c option was PR_SET_SPECULATION_CTRL and @c ...arg3 is not
/// PR_SPEC_ENABLE, PR_SPEC_DISABLE, PR_SPEC_FORCE_DISABLE, nor
/// PR_SPEC_DISABLE_NOEXEC.
int prctl_(int option, ...);

}


#endif